package leetcode;

import java.util.ArrayDeque;
import java.util.Queue;

public class LeetCode98 {

    public boolean isValidBST1(TreeNode root) {
        if (root == null)
            return true;
        Queue<TreeNode> queue = new ArrayDeque<>();
        queue.add(root);
        while (!queue.isEmpty()) {
            TreeNode node = queue.poll();
            if (node.left != null) {
                if (node.left.val < node.val)
                    queue.add(node.left);
                else
                    return false;
            }
            if (node.right != null)
                if (node.right.val > node.val)
                    queue.add(node.right);
                else
                    return false;
        }
        return true;
    }
//------------------------------------------------------------------

    public boolean isValidBST(TreeNode root) {
        return false;
    }
}
